< previous page page_489 next page >

Page 489
e10a6a0a59f035e870d90cca05b85fce.gif
    ' Draw to the last point if necessary. 
    If Not skipping Then _ 
        pic.Line (firstx, firsty)-(x2, y2) 
End Sub
Example program HiLo uses the HiLoGrid3d class to display surfaces with hidden lines removed. Use the option buttons to select the surface you want to display. Use the Remove Hidden check box to tell the program whether it should display the hidden portions of the surface.
Restrictions
In order for the Hi-Lo algorithm to work correctly, your program must meet a couple of constraints. First, the object you display must be a surface defined by a grid. The Hi-Lo algorithm uses the ordering imposed on the data by the grid to display the areas in the correct order. The algorithm will not work as it is described here for displaying other objects such as cubes and spheres. More general algorithms that handle these cases are described in later chapters.
Second, the algorithm is not guaranteed to work with perspective projections. In a perspective projection, the area you are drawing can sometimes be obscured by an area that you draw later. The front edges of the surface are not always visible. The picture on the left in Figure 14.13 shows a parallel projection of a surface with hidden surfaces removed. The edges with the largest X and Z coordinates are drawn in heavy lines. The picture on the right shows a perspective projection of the same surface with the same direction of projection. Because the center of projection is quite close to the surface, foreshortening makes closer regions much larger than those further from the center of projection. Some of the closer regions obscure parts of the front edge that have the largest Z values.
z0509-01.gif
Figure 14.13
The Hi-Lo algorithm works for parallel projections (left)
but not all perspective projections.

 
< previous page page_489 next page >